package com.shujia.MR.output;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

/**
 * 对学生的总分进行排序，并且为倒排
 * 数据源：    1500100001	施笑槐*22*女*文科六班*406
 *
 * 输出：
 *      将学生成绩进行划分，大于450分存放至一个文件中，其他存放至另外一个文件中
 *
 */
public class OutDriver {
    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf);

        job.setJobName("Sort");
        job.setJarByClass(OutDriver.class);

        job.setMapperClass(OutMapper.class);

        job.setMapOutputKeyClass(Student.class);
        job.setMapOutputValueClass(NullWritable.class);
        job.setOutputKeyClass(Student.class);
        job.setOutputValueClass(NullWritable.class);

        job.setOutputFormatClass(MyOutputFormat.class);


        FileInputFormat.addInputPath(job, new Path("D:\\workspace19\\HadoopCode\\output\\joinOutRes"));
        FileOutputFormat.setOutputPath(job, new Path("D:\\workspace19\\HadoopCode\\output\\outRes"));

        job.waitForCompletion(true);
    }
}
